﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using ManageEmployees.Properties;
using ManageEmployees.Models;
using System.Linq;

namespace ManageEmployees
{
    public partial class fOrganizarions : fBase
    {
        #region Constructors
        public fOrganizarions()
        {
            InitializeComponent();
        }
        #endregion

        #region Form Load
        private void fOrganizarions_Load(object sender, EventArgs e)
        {
            Text = Resources.OrganizationFormManager;
        }
        #endregion

        #region Events
        private void iAdd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            new fOrganizationInfo().ShowDialog();
        }

        private void iUpdate_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string organID = "";
            Organization objOrgan = Utility.GetOrganizationByOrganID(organID);
            List<Organization> listOrgan = Utility.GetOrganizationsByParentID(organID);
            new fOrganizationInfo(objOrgan).ShowDialog();
        }

        private void iDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Delete();
        }

        private void iExit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Close();
        }
        #endregion

        #region Functions

        private void Delete()
        {
            Organization objOrgan = new Organization();
            if (XtraMessageBox.Show(Resources.DoYouWantDelete, Resources.Notification, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {
                XtraMessageBox.Show(Resources.DeleteSuccess, Resources.Notification, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                XtraMessageBox.Show(Resources.DeleteError, Resources.Notification, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        #endregion
    }
}